package com.sunwayhorizo.health.business.patad.encounter.query;

import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.ejb.Local;

import com.sunwayhorizo.health.business.base.query.BaseQueryLocal;
import com.sunwayhorizo.health.hl7.common.Hl7Exception;
import com.sunwayhorizo.health.hl7.persistent.RimCoreActPrtcptns;
import com.sunwayhorizo.health.hl7.rim.PatientEncounter;
import com.sunwayhorizo.health.hl7.rim.Role;

@Local
public interface PatientEncounterQueryLocal extends BaseQueryLocal
{

    /**
     * 查询入院信息
     * 
     * @Title: findPatientEncounterById
     * @param id
     *            就诊号
     * @return PatientEncounter 入院登记动作
     * @throws Hl7Exception
     * @firstAuthor Obama
     * @firstTime 2011-03-30 16:30:15
     * @lastAuthor Obama
     * @lastTime 2011-03-30 16:30:15
     */
    // PatientEncounter findPatientEncounterById(String id) throws Hl7Exception;

    // PatientEncounter findPatientEncounterByActId(String actId) throws
    // Hl7Exception;

    // PatientEncounter findLastPatientEncounter(String patientNatureId) throws
    // Hl7Exception;

    // List<PatientEncounter> findAllPatientEncounter(String patientNatureId)
    // throws Hl7Exception;

    // PatientEncounter findInhospitalPatientEncounterById(String id) throws
    // Hl7Exception;

    // PatientEncounter findRecieveingEncounterByPatientRoleId(String roleId);

    /**
     * 根据条件查询就诊流程动作
     * 
     * @Title: baseEncounterQuery
     * @param conditions
     *            查询条件
     * @param pageNo
     *            第几页
     * @param pageSize
     *            每页几条数据
     * @return List<PatientEncounter> 患者就诊流程动作
     * @throws Hl7Exception
     * @firstAuthor Obama
     * @firstTime 2011-06-21 16:30:15
     * @lastAuthor Obama
     * @lastTime 2011-06-21 16:30:15
     */
    List<PatientEncounter> baseEncounterQuery(Map<String, Map<String, Object>> conditions, int pageNo, int pageSize) throws Hl7Exception;


    /**
     * 根据条件查询就诊流程动作总数
     * 
     * @Title: baseEncounterQuery
     * @param conditions
     *            查询条件
     * @return long 所有值个数
     * @throws Hl7Exception
     * @firstAuthor Obama
     * @firstTime 2011-06-21 16:30:15
     * @lastAuthor Obama
     * @lastTime 2011-06-21 16:30:15
     */
    long baseCountEncounterQuery(Map<String, Map<String, Object>> conditions) throws Hl7Exception;


    PatientEncounter findActiveInhosActByII(String ii) throws Hl7Exception;


    PatientEncounter findActiveIndepartmentActByII(String encounterId) throws Hl7Exception;


    PatientEncounter findTransferPatientEncounter(String patientNatureId) throws Hl7Exception;


    PatientEncounter findLastAvtiveIndepartmentPatientEncounter(String patientNatureId) throws Hl7Exception;


    PatientEncounter findLastAvtiveRecievingPatientEncounter(String patientNatureId) throws Hl7Exception;


    List<PatientEncounter> findPatientEncountersByDoctorRoleIdAndStatusCode(String roleId, List<String> statusCode, int pageNo, int pageSize)
        throws Hl7Exception;


    List<PatientEncounter> findPatientEncountersByWorkgroupIdsAndStatusCode(String workGroupRoleId, List<String> statusCode, int pageNo, int pageSize)
        throws Hl7Exception;


    RimCoreActPrtcptns findRecieveingEncounterById(String id) throws Hl7Exception;


    PatientEncounter findActiveRecieveingEncounterById(String id) throws Hl7Exception;


    PatientEncounter findLastCompleteTransferPatientEncounter(String encounterId) throws Hl7Exception;


    List<PatientEncounter> findAllActiveIndepartments(String workgroupId, int pageNo, int pageSize) throws Hl7Exception;


    PatientEncounter findLastCompleteIndepartment(String encounterId) throws Hl7Exception;


    PatientEncounter findLastCompleteRecieving(String encounterId) throws Hl7Exception;


    PatientEncounter findLastActiveTransfer(String encounterId) throws Hl7Exception;


    List<PatientEncounter> findAllActivePE(String encounterId) throws Hl7Exception;


    List<PatientEncounter> findAllActivePEByPatientId(String natureId) throws Hl7Exception;


    PatientEncounter findLastInhosActByEncounterId(String encounterId) throws Hl7Exception;


    PatientEncounter findLastInhosActByPatientNatureId(String id) throws Hl7Exception;


    PatientEncounter findRecieveingEncounterByPatientRoleId(String roleId) throws Hl7Exception;


    List<PatientEncounter> findPatientByBedNoAndWorkgroupId(String bedNo, String workgroupId) throws Hl7Exception;


    List<PatientEncounter> findIndepartment(String workgroupId, int pageNo, int pageSize) throws Hl7Exception;


    List<PatientEncounter> findAllActiveInhospital(String workgroupId, int pageNo, int pageSize) throws Hl7Exception;


    List<PatientEncounter> findAllActiveTransfer(String workgroupId, int pageNo, int pageSize) throws Hl7Exception;


    long findAllActiveIndepartmentsCount(String workgroupId) throws Hl7Exception;


    long findCountIndepartment(String workgroupId) throws Hl7Exception;


    PatientEncounter findLastIndepartment(String encounterId) throws Hl7Exception;


    long findCountAllActiveInhospital(String workgroupId) throws Hl7Exception;


    long findCountAllActiveTransfer(String workgroupId) throws Hl7Exception;


    long findMyPatientsByDoctorCount(String roleId, List<String> statusCode) throws Hl7Exception;


    long findMyPatientInGroup(String workGroupRoleId, List<String> statusCode) throws Hl7Exception;


    List<PatientEncounter> findAllReceivingByPatientId(String patientId) throws Hl7Exception;


    PatientEncounter findLastReceving(String patientId) throws Hl7Exception;


    PatientEncounter findLastRecevingByRoleId(String patientId) throws Hl7Exception;


    PatientEncounter findLastRemoved(String patientId) throws Hl7Exception;


    PatientEncounter findInhosBytime(Date admission_time, String patientId) throws Hl7Exception;


    PatientEncounter findLastRecevingById(String encounterId) throws Hl7Exception;


    long findInhostNumByNatureId(String natureId);


    PatientEncounter findOutPatientEncounter(String natureId) throws Hl7Exception;


    List<PatientEncounter> findAllActiveRecieveing() throws Hl7Exception;


    /**
     * 根据患者查找患者的入院次数
     * 
     * @param roleId
     * @return
     * @throws Hl7Exception
     */
    PatientEncounter findLastInHosActByPatientRoleId(String roleId) throws Hl7Exception;


    /**
     * 
     * @param workgroupId
     * @param pageNo
     * @param pageSize
     * @param patientName
     * @return
     * @throws Hl7Exception
     */
    List<PatientEncounter> findAllActiveInhospital(String workgroupId, int pageNo, int pageSize, String patientName) throws Hl7Exception;


    /**
     * 
     * @param natureId
     * @return
     * @throws Hl7Exception
     */
    PatientEncounter findLastAvtiveOutHos(String natureId) throws Hl7Exception;


    /**
     * 
     * @param workgroupId
     * @param pageNo
     * @param pageSize
     * @param patientName
     * @return
     * @throws Hl7Exception
     */
    long findCountAllActiveInhospital(String workgroupId, int pageNo, int pageSize, String patientName) throws Hl7Exception;


    List<PatientEncounter> findPatientEncountersByDoctorRoleIdAndStatusCode(String roleId, List<String> statusCode, int pageNo, int pageSize,
        String patientName);


    /**
     * 根据病案号查询最后一次入科动作
     * 
     * @param hospitalNo
     * @return
     * @throws Hl7Exception
     */
    PatientEncounter findLastIndepartmentByHosNo(String hospitalNo) throws Hl7Exception;


    /**
     * 根据诊断号、住院次数和动作类型查询患者动作
     * 
     * @param encounterId
     *            诊断号
     * @param encounterNum
     *            住院次数
     * @param actCodeString
     *            动作code类型
     * @return
     * @throws Hl7Exception
     */
    PatientEncounter findActByEncounterIdAndNumAndActCode(String encounterId, String encounterNum, String actCodeString) throws Hl7Exception;


    /**
     * 根据病人查询床号
     * 
     * @param id
     * @return
     */
    Role findBedRoleByPatientRoleId(String id);


    /**
     * 查询我的患者
     * 
     * @param roleId
     * @param statusCode
     * @param patientName
     * @return
     */
    long findCountMyPatients(String roleId, List<String> statusCode, String patientName);
}
